﻿using Mate.Core.Base;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;

namespace Mate.Db.SqlSugar
{
    public interface IDataService<T> : IDisposable where T : BaseModel, new()
    {
        ISugarQueryable<T> Queryable { get; }

        ISugarQueryable<T1, T2> QueryableJoin<T1, T2>(Expression<Func<T1, T2, object[]>> joinExpression);

        ISugarQueryable<T1, T2,T3> QueryableJoin<T1, T2,T3>(Expression<Func<T1, T2,T3, object[]>> joinExpression);

        #region get model
        T Get(Expression<Func<T, bool>> where, Expression<Func<T, object>> orderBy = null, OrderByType orderByType = OrderByType.Asc);
        #endregion

        IList<T> GetList(Expression<Func<T, bool>> where, Expression<Func<T, object>> orderBy = null, OrderByType orderByType = OrderByType.Asc);

        IList<T> GetPageList(int pageIndex, int pageSize, Expression<Func<T, bool>> where, Expression<Func<T, object>> orderBy, ref int totalCount, OrderByType orderByType = OrderByType.Asc);

        int Insert(T model);

        int Update(T model);

        int Update(T model, Expression<Func<T, object>> updateColumns, Expression<Func<T, object>> whereColumns);

        int UpdateIgnore(T model, Expression<Func<T, object>> ignoreColumns, Expression<Func<T, object>> whereColumns);

        int Delete(Expression<Func<T, bool>> expression);
    }
}
